import { TodoAction, TodoFilterType } from '../reducer/todo';

// 5.3创建删除Action函数
export const delTodoById = (id: number): TodoAction => {
  return {
    type: 'todo/delById',
    payload: id,
  };
};

// 6.3 创建更新的Action函数
export const updateTodoById = (id: number): TodoAction => {
  return {
    type: 'todo/updateById',
    payload: id,
  };
};

// 7.4 创建清除的Action函数
export const clearIsDoneTodo = (): TodoAction => {
  return {
    type: 'todo/clearIdDone',
  };
};

// 10.3 创建更新type 的Action函数
export const updateType = (type: TodoFilterType): TodoAction => {
  return {
    type: 'todo/selectType',
    payload: type,
  };
};

// 13.3 定义新增Todo的Aciton函数
export const addTodo = (newTask: string): TodoAction => ({
  type: 'todo/addTodo',
  payload: newTask,
});

// 16.4 定义全选的action函数
export const checkedAllTodo = (checked: boolean): TodoAction => ({
  type: 'todo/checkedAll',
  payload: checked,
});
